var http = require('http');

function getResponseData(req, res, next) {
  var webServiceCaller = http.get(req.params.webServiceUrl,function(response){
    var responseData='';
    response.on('data',function(data){
      responseData+=data;
    });
    response.on('end',function(){
      res.send({status:response.statusCode,data:responseData})
    });
  });
    webServiceCaller.on('error', function(err) {
    console.log("it's coming");
    res.send({status:'500', data: req.params.webServiceUrl+" can't be accessed"});
  })
}

module.exports = {
  getResponseData:getResponseData
}